/**
 * 设备数据操作
 */
var lean = require('../../../base//lean.js');

// 根据小区ID获取设备列表
exports.device_list = function(communityId,callback) {
    var cqlString_deviceList = "select * from Device where d_c=pointer('Community','" + communityId + "')";
    lean.cql(cqlString_deviceList,function(deviceList){
        var deviceList = deviceList.results;
        callback(deviceList);
    })
}

// 新增设备
exports.device_new = function(position,communityId,callback) {
    var cqlString_newDevice = "insert into Device (d_position,d_c) VALUES ('" + position + "',pointer('Community','" + communityId + "'))";
    lean.cql(cqlString_newDevice,function(data){
        var results = data.results;
        callback(results);
    });
}

// 删除单个设备
exports.device_del = function(deviceId,callback) {
    var cqlString_delDevice = "delete from Device where objectId = '" + deviceId + "'";
    lean.cql(cqlString_delDevice,function(data){
        var results = data;
        callback(results);
    });

}
